/***************************************************************************
*  Configurebase.cpp
*
*  July 2007
*  Copyright  2007  RuijinZheng,China
*  Email mebetop@126.com
****************************************************************************/

/*
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
#include <QSettings>
#include "Configurebase.h"
bool ConfigureBase::readSettings()
{
     QSettings settings("mebetop@126.com","netflea");
     settings.beginGroup("Configuration");
     bool flag = settings.contains("Configuration/global/fleatype");
     settings.endGroup();
     if(flag==false){
          return false;
     }
     else
     { 

         settings.beginGroup("Configuration");
          this->x= settings.value("Configuration/geometry/mainwindowx", 800).toInt();
          this->y= settings.value("Configuration/geometry/mainwindowy", 0).toInt();
          this->proxytype = settings.value("Configuration/global/fleatype","Normal").toString().toStdString();
          this->savelog = settings.value("Configuration/global/savelog",false).toBool();
          this->connecttimeout = settings.value("Configuration/global/connecttimeout",20).toInt();        
          this->maxport = settings.value("Configuration/global/udpmaxport",60000).toInt();
          this->minport = settings.value("Configuration/global/udpminport",10000).toInt();
          settings.endGroup();
          return true;
    }

}
void ConfigureBase::writeSettings()
{

     QSettings settings("mebetop@126.com","netflea");
     settings.beginGroup("Configuration");
     settings.setValue("Configuration/geometry/mainwindowx", this->x);
     settings.setValue("Configuration/geometry/mainwindowy", this->y);
     settings.setValue("Configuration/global/fleatype",QString::fromStdString(this->proxytype));
     settings.setValue("Configuration/global/savelog",this->savelog);
     settings.setValue("Configuration/global/connecttimeout",this->connecttimeout);
     settings.setValue("Configuration/global/udpmaxport",this->maxport);
     settings.setValue("Configuration/global/udpminport",this->minport);
     settings.endGroup();
     settings.sync();

}
